<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<script type="text/javascript">
		var path = '${pageContext.request.contextPath}';
		window.UEDITOR_SELF_DEF_URL = path + "/";
    </script>
    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/assets/plugin/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/assets/plugin/ueditor/ueditor.all.min.js"></script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/assets/plugin/ueditor/lang/zh-cn/zh-cn.js"></script>
    <style type="text/css">
        edit-container{
            width:100%;
        }
    </style>
    <script type="text/javascript">
		UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
		UE.Editor.prototype.getActionUrl = function(action) {
		    if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadvideo' || action == 'uploadfile') {
		        return path + '/ueditor/uploadFileImage';
		    } else if (action == 'catchimage') {
		        return path + '/ueditor/catchNetworkImage';
		    } else if (action == 'listimage') {
		        return path + '/ueditor/listImage';
		    } else if (action == 'listfile') {
		        return path + '/ueditor/listFile';
		    } else {
		        return this._bkGetActionUrl.call(this, action);
		    }
		}
	</script>
</head>
<body>
	<!-- PAGE CONTENT BEGIN -->
	<div class="right-area">
		<h3>编辑活动</h3>
		<form id="inputForm" name="inputForm"
			action="${pageContext.request.contextPath}/activity/save"
			method="post">
			<input type="hidden" name="id" value="${activity.id}">
			<table class="table">
				<tbody>
					<tr>
						<th class="first minw120">标题</th>
						<th class="second maxw300">
							<div class="text-input">
								<input type="text" name="titile" maxlength="50"
									value="${activity.title}" class="required" 
									title="必选字段" />
							</div>
						</th>
					</tr>
					<tr>
						<th class="first minw120">时间</th>
						<th class="second maxw300">
							<div class="text-input">
								<input type="text" class="required" name="activityTime" value="<fmt:formatDate value="${activity.activityTime }" pattern="yyyy-MM-dd HH:mm"/>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true});" />
							</div>
						</th>
					</tr>
					<tr>
						<th class="first minw120">地点</th>
						<th class="second maxw300">
							<div class="text-input">
								<input type="text" class="required" name="address" value="${activity.address}" maxlength="100"/>
							</div>
						</th>
					</tr>
					<tr>
						<th class="first minw120">内容 </th>
						<th class="second">
							<div class="edit-container">
		    					<script id="editor1" type="text/plain" style="width:600px;height:300px;"></script>
		    					<input type="hidden" id="content1" name="walletdescr" value='${activity.content}'>
		    					
							</div>
						</th>
					</tr>
				</tbody>
			</table>
			<div class="btn-box">
				<input class="active" type="submit" value="确定">
				<input type="button" value="取消" onclick="javascript:history.go(-1);">
			</div>
		</form>
	</div>
	<!-- PAGE CONTENT END -->
	<script type="text/javascript">
	var path = '${pageContext.request.contextPath}';
	$(function(){
		$("#inputForm").validate({
			submitHandler:function(form){ 
		    	if(confirm("确定要提交吗？")){
		    		$("#content1").val(ue1.getContent());
					form.submit();
		    	}
			},
			errorPlacement: function (error, element) { //指定错误信息位置
				if (element.is(':radio') || element.is(':checkbox')) { //如果是radio或checkbox
					var eid = element.attr('name'); //获取元素的name属性
					error.appendTo(element.parent().parent().parent()); //将错误信息添加当前元素的父结点后面
				} else if(element.is('input:text') || element.is('textarea')){
					error.insertAfter(element);
				}else{
					error.insertAfter(element);
				}
			}
		});
	});
	//实例化编辑器
	//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
	
	var ue1 = UE.getEditor('editor1', {
// 		toolbars: [
// 		    ['fullscreen', 'source', 'undo', 'redo'],
// 		    ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc']
// 		],
		initialFrameHeight : 300,
		scaleEnabled : true
	});
	 ue1.ready(function() {//编辑器初始化完成再赋值 
		ue1.setContent('${activity.content}', false);
	}); 
</script>
</body>
</html>